﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文件上传示例</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
    <script src="https://unpkg.com/element-plus/dist/index.full.min.js"></script>
    <style scoped>
        .app-container {
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .header {
            height: 69px;
            background: #005EB8;
            color: white;
            padding: 0 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        .logo {
            height: 40px;
            margin-right: 20px;
        }

        .header-right button {
            margin-left: 15px;
            padding: 6px 12px;
            background: #FF6B6B;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        .main-layout {
            flex: 1;
            display: flex;
        }

        .sidebar {
            width: 200px;
            background: #F5F7FA;
            border-right: 1px solid #E4E7ED;
        }

        .main-content {
            flex: 1;
            padding: 20px;
            background: white;
        }

    </style>
</head>
<body>
    <div id="app" class="app-container">
        <!-- 顶部导航栏 -->
        <div class="header">
            <img src="https://example.com/bette-logo.png" alt="Bette伯乐" class="logo" />
            <div class="header-right">
                <span>欢迎你，{{ userInfo.username }}</span>
                <button v-on:click="handleLogout">退出登录</button>
            </div>
        </div>

        <!-- 主体布局 -->
        <div class="main-layout">
            <!-- 左侧菜单栏 -->
            <div class="sidebar">
                <el-menu :default-openeds="['1']" mode="vertical" v-on:select="handleMenuSelect">
                    <el-sub-menu index="1">
                        <template #title><i class="el-icon-s-management"></i> 基础管理</template>
                        <el-menu-item index="1-1">员工管理</el-menu-item>
                        <el-menu-item index="1-2">部门管理</el-menu-item>
                        <el-menu-item index="1-3">岗位管理</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="2">
                        <template #title><i class="el-icon-s-data"></i> 人力资源管理</template>
                        <el-menu-item index="2-1">招聘管理</el-menu-item>
                        <el-menu-item index="2-2">培训管理</el-menu-item>
                        <el-menu-item index="2-3">绩效考核</el-menu-item>
                    </el-sub-menu>
                </el-menu>
            </div>

            <!-- 主内容区域 -->
            <div class="main-content">
                <router-view></router-view>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        const { createApp, ref } = Vue
        const app = createApp({
            setup() {
                const userName = ref('');
                const userPassword = ref('');

                // 处理登录逻辑
                async function handleLogin() {

                try {
                const response = await axios.post("/Text/Login",
                    { username: userName.value, password: userPassword.value },
                    { headers: { "Content-Type": "application/json" } } // 显式设置
                );

                if (response.data.success) {
                    alert("登录成功");
                } else {
                    alert("登录失败: " + response.data.message);
                }
                } catch (error) {
                console.error(error);
                 alert("登录失败: " + (error.response?.data?.message || "未知错误"));
               }

                }

                return {
                    userName,
                    userPassword,
                    handleLogin
                }
            }
        });

        app.use(ElementPlus);
        app.mount('#app'); // 确保挂载到正确的DOM元素
    </script>
</body>
</html>